<%@page import="tools.MyTool"%>
<%@page import="java.util.Iterator"%>
<%@page import="accessor.HomeProductAccessor"%>
<%@page import="accessor.Products"%>
<%@include file="no_banner_header.jsp" %>

<%
    if (customer == null) {
        response.sendRedirect("login_order.jsp");
    }
%>
<%
    List<Products> cartOrder = new ArrayList<Products>();
    Double totalPrice = 0.0;
    if (request.getSession().getAttribute("cart") != null) {
        cartOrder = (List<Products>) request.getSession().getAttribute("cart");
    } else {
        response.sendRedirect("index.jsp");
    }

%>
<link href="../assets/css/frontend/order.css" rel="stylesheet" type="text/css" media="screen" />
<div>
    <script>
        $(document).ready(function() {
            $('#step4').addClass('current');
        });
    </script>
    <div id="order_step">
        <h4>Steps of Order</h4>
        <p>
            <a id="step1" href="home_order.jsp">Products</a>
            <a id="step2" href="login_order.jsp">Login</a>
            <a id="step3" href="address_order.jsp">Address</a>
            <a id="step4" href="sumary_order.jsp">Order</a>
        </p>
    </div>

    <form action="../do_order" method="post" accept-charset="utf-8"><div class="break_line"></div>   
        <table id="order_table" cellspacing="1" cellpadding="6" border="0" style="width:100%">
            <tbody>
                <tr>
                    <th class="table_title_td" >Product Name</th>
                    <th  width="70">Image</th>
                    <th width="40">Qty</th>
                    <th width="80">Price</th>
                    <th width="80">Total</th>
                </tr>
                <%for (int index = 0; index < cartOrder.size(); index++) {
                        Products item = cartOrder.get(index);
                        totalPrice += item.getPrice() * item.getQuantity();

                %>
                <tr>                  
                    <td class="table_title_td"><%=item.getProductName()%></td>        
                    <td><img src="../assets/img/p/<%=item.getDefaultImage()%>" width="64" height="48" style="border: 0px solid #DDDDDD;" />
                    </td>
                    <td>
                        <%=item.getQuantity()%>
                    </td>
                    <td>$<%=item.getPrice()%></td>
                    <td>$<span id="price_id_<%=item.getProductID()%>"><%=item.getPrice() * item.getQuantity()%></span></td>
                </tr>       
                <%}%>
                <tr id="total_footer">
                    <td colspan="3"></td>
                    <td class="right"><strong>Total</strong></td>
                    <td>$<span id="cart_total"><%=totalPrice%></spsan></td>
                </tr>
              
            </tbody>
        </table>
        <input type="button" id="shop_more" class="submit" value="Shop more" size="30" onclick="window.location.href='listing.jsp'" />        
        <input type="submit" class="submit" value="ORDER" name="btnOrder" style="float:right;margin-right: 20px;"/>
    </form>
</div>                              

<div style="clear: both;">&nbsp;</div>
<%@include file="footer.jsp" %>